<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Page Title</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>
    #imgList {
      padding: 0;
      margin: 0;
    }
    
    #imgList li {
      display: inline-block;
    }
    
    #imgList li img {
      width: 60px;
    }
  </style>
</head>

<body>
  <a href="/">首页</a>
  <a href="/user">用户</a>
  <a href="/home">家里</a>
  <form action="/fileupload" method="POST" enctype="multipart/form-data" onsubmit="return checkTask(this)">
    <label for="resource">上传文档</label>
    <input type="file" id="resource" name="resource">
    <button type="submit">新建任务</button>
  </form>
  <ul id="imgList">

  </ul>
</body>
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js"></script>
<script>
  $.ajax({
    url: "/api/imgList",
    method: 'get',
    success: function(result) {
      result.forEach(item => {
        $('#imgList').append(`<li> <img src="data:image/jpg;base64,${item.imgData}" /> <a href="download/${item.imgName}">下载</a></li>`)
      });
    }
  });
  var socket = io('http://localhost:8020');
  socket.on('news', function(data) {
    var i = 0;
    setInterval(function() {
      socket.emit('my other event', {
        count: i++
      })
    }, 200000)
  });
  var imgList = document.querySelectorAll('#imgList');
</script>

</html>